package com.ruoyi.profession.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.profession.domain.ProfessionalTitle;
import com.ruoyi.profession.service.IProfessionalTitleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 职称证书信息Controller
 * 
 * @author 职称管理系统
 * @date 2024-06-02
 */
@RestController
@RequestMapping("/profession/professionalTitle")
public class ProfessionalTitleController extends BaseController
{
    @Autowired
    private IProfessionalTitleService professionalTitleService;

    /**
     * 查询职称证书信息列表
     */
    @PreAuthorize("@ss.hasPermi('profession:professionalTitle:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProfessionalTitle professionalTitle)
    {
        startPage();
        List<ProfessionalTitle> list = professionalTitleService.selectProfessionalTitleList(professionalTitle);
        return getDataTable(list);
    }

    /**
     * 导出职称证书信息列表
     */
    @PreAuthorize("@ss.hasPermi('profession:professionalTitle:export')")
    @Log(title = "职称证书信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProfessionalTitle professionalTitle)
    {
        List<ProfessionalTitle> list = professionalTitleService.selectProfessionalTitleList(professionalTitle);
        ExcelUtil<ProfessionalTitle> util = new ExcelUtil<ProfessionalTitle>(ProfessionalTitle.class);
        util.exportExcel(response, list, "职称证书信息数据");
    }

    /**
     * 获取职称证书信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('profession:professionalTitle:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(professionalTitleService.selectProfessionalTitleById(id));
    }

    /**
     * 新增职称证书信息
     */
    @PreAuthorize("@ss.hasPermi('profession:professionalTitle:add')")
    @Log(title = "职称证书信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProfessionalTitle professionalTitle)
    {
        return toAjax(professionalTitleService.insertProfessionalTitle(professionalTitle));
    }

    /**
     * 修改职称证书信息
     */
    @PreAuthorize("@ss.hasPermi('profession:professionalTitle:edit')")
    @Log(title = "职称证书信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProfessionalTitle professionalTitle)
    {
        return toAjax(professionalTitleService.updateProfessionalTitle(professionalTitle));
    }

    /**
     * 删除职称证书信息
     */
    @PreAuthorize("@ss.hasPermi('profession:professionalTitle:remove')")
    @Log(title = "职称证书信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(professionalTitleService.deleteProfessionalTitleByIds(ids));
    }
}
